﻿
namespace RestaurantCommon
{
    public class SaveResult
    {
        private readonly bool _ok;
        private readonly string _externalId;
        private readonly decimal? _externalNumber;
        private readonly string _externalUserName;
        private readonly string _errorMessage;

        protected SaveResult(bool ok, string externalId, decimal? externalNumber, string externalUserName, string errorMessage)
		{
			_ok = ok;
		    _externalId = externalId;
            _externalNumber = externalNumber;
            _externalUserName = externalUserName;
            _errorMessage = errorMessage;
        }

        public bool OK
		{
			get { return _ok; }
		}

        public string ExternalId
		{
            get { return _externalId; }
		}

        public decimal? ExternalNumber
        {
            get { return _externalNumber; }
        }

        public string ExternalUserName
        {
            get { return _externalUserName; }
        }

        public string ErrorMessage
        {
            get { return _errorMessage; }
        }

        public static SaveResult Success(string externalId, decimal? externalNumber, string externalUserName)
		{
            return new SaveResult(true, externalId, externalNumber, externalUserName, "");
		}

        public static SaveResult Failure(string errorMessage)
		{
            return new SaveResult(false, "", null, "", errorMessage);
		}
    }
}
